{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f45aeb52",
   "metadata": {},
   "source": [
    "##### 第二章 -数据类型、运算符和内置函数\n",
    "\n",
    "##### 编程题：工资统计\n",
    "###### 某公司有一份员工工资表，工资数据如下（单位：元）：\n",
    "salaries = [5500, 7200, 6600, 8000, 5200, 9100, 6100, 7000, 8300, 5900]\n",
    "\n",
    "###### 要求：\n",
    "###### 1. 计算所有员工的平均工资（使用内置函数）。\n",
    "###### 2. 找出工资高于平均工资的员工数量（使用运算符和内置函数）。\n",
    "###### 3. 将所有工资按从高到低排序（使用内置函数）。\n",
    "###### 4. 输出排序后的工资列表。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1bf916b5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-30T02:19:21.508126Z",
     "start_time": "2025-05-30T02:19:21.493095Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均工资： 6890.0 元\n",
      "工资高于平均工资的员工数量： 5 人\n",
      "排序后的工资列表： [9100, 8300, 8000, 7200, 7000, 6600, 6100, 5900, 5500, 5200]\n"
     ]
    }
   ],
   "source": [
    "salaries = [5500, 7200, 6600, 8000, 5200, 9100, 6100, 7000, 8300, 5900]\n",
    "\n",
    "# 1. 计算所有员工的平均工资\n",
    "average_salary = sum(salaries) / len(salaries)\n",
    "print(\"平均工资：\", average_salary, \"元\")\n",
    "\n",
    "# 2. 找出工资高于平均工资的员工数量\n",
    "above_average_count = len([salary for salary in salaries if salary > average_salary])\n",
    "print(\"工资高于平均工资的员工数量：\", above_average_count, \"人\")\n",
    "\n",
    "# 3. 将所有工资按从高到低排序\n",
    "salaries.sort(reverse=True)\n",
    "\n",
    "# 4. 输出排序后的工资列表\n",
    "print(\"排序后的工资列表：\", salaries)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8850f39c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "成绩在90分及以上的学生人数： 2\n",
      "分数最低的学生姓名： 王五\n",
      "所有学生姓名： 张三, 李四, 王五, 赵六, 钱七\n"
     ]
    }
   ],
   "source": [
    "# 编程题：学生成绩处理\n",
    "# 某班有一组学生姓名和对应的成绩如下：\n",
    "students = [\"张三\", \"李四\", \"王五\", \"赵六\", \"钱七\"]\n",
    "scores = [85, 92, 78, 90, 88]\n",
    "\n",
    "# 要求：\n",
    "# 1. 统计成绩在90分及以上的学生人数（使用运算符和内置函数）。\n",
    "# 2. 找出分数最低的学生姓名（结合数据类型和内置函数）。\n",
    "# 3. 将所有学生姓名用英文逗号连接成一个字符串（使用字符串方法和内置函数）。\n",
    "# 4. 输出上述结果。\n",
    "\n",
    "# 1. 统计成绩在90分及以上的学生人数\n",
    "high_score_count = len([score for score in scores if score >= 90])\n",
    "print(\"成绩在90分及以上的学生人数：\", high_score_count)\n",
    "\n",
    "# 2. 找出分数最低的学生姓名\n",
    "min_score = min(scores)\n",
    "min_index = scores.index(min_score)\n",
    "min_student = students[min_index]\n",
    "print(\"分数最低的学生姓名：\", min_student)\n",
    "\n",
    "# 3. 将所有学生姓名用英文逗号连接成一个字符串\n",
    "students_str = \", \".join(students)\n",
    "print(\"所有学生姓名：\", students_str)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "699bec6a",
   "metadata": {},
   "source": [
    "##### 第三章 -列表、元组、字典、集合与字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "35741c83",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "按类别分组的图书信息： {'计算机': ['Python编程', '数据结构'], '数学': ['高等数学', '线性代数'], '历史': ['世界历史', '中国通史']}\n",
      "每个类别下的图书数量： {'计算机': 2, '数学': 2, '历史': 2}\n",
      "所有作者姓名（去重后按字母顺序）： ['孙健', '张伟', '李明', '王芳', '赵强', '钱丽']\n",
      "所有馆藏编号： A001; A002; B001; B002; C001; C002\n"
     ]
    }
   ],
   "source": [
    "# 编程题：图书信息管理\n",
    "# 某图书馆有如下图书信息（书名、作者、类别、馆藏编号）：\n",
    "books = [\n",
    "    (\"Python编程\", \"张伟\", \"计算机\", \"A001\"),\n",
    "    (\"数据结构\", \"李明\", \"计算机\", \"A002\"),\n",
    "    (\"高等数学\", \"王芳\", \"数学\", \"B001\"),\n",
    "    (\"线性代数\", \"赵强\", \"数学\", \"B002\"),\n",
    "    (\"世界历史\", \"钱丽\", \"历史\", \"C001\"),\n",
    "    (\"中国通史\", \"孙健\", \"历史\", \"C002\")\n",
    "]\n",
    "\n",
    "# 要求：\n",
    "# 1. 将所有图书信息按类别分组，存储为字典，键为类别，值为该类别下所有书的书名列表。\n",
    "# 2. 统计每个类别下的图书数量，结果以字典形式输出。\n",
    "# 3. 提取所有作者姓名，去重后按字母顺序输出（使用集合和字符串方法）。\n",
    "# 4. 输出所有馆藏编号组成的字符串，每个编号之间用英文分号分隔。\n",
    "\n",
    "# 请在下方编写代码实现上述功能。\n",
    "\n",
    "# 1. 将所有图书信息按类别分组，存储为字典\n",
    "books_by_category = {}\n",
    "for book in books:\n",
    "    title, author, category, id = book\n",
    "    if category not in books_by_category:\n",
    "        books_by_category[category] = []\n",
    "    books_by_category[category].append(title)\n",
    "print(\"按类别分组的图书信息：\", books_by_category)\n",
    "\n",
    "# 2. 统计每个类别下的图书数量\n",
    "category_counts = {category: len(titles) for category, titles in books_by_category.items()}\n",
    "print(\"每个类别下的图书数量：\", category_counts)\n",
    "\n",
    "# 3. 提取所有作者姓名，去重后按字母顺序输出\n",
    "authors = {book[1] for book in books}\n",
    "sorted_authors = sorted(authors)\n",
    "print(\"所有作者姓名（去重后按字母顺序）：\", sorted_authors)\n",
    "\n",
    "# 4. 输出所有馆藏编号组成的字符串\n",
    "ids = [book[3] for book in books]\n",
    "ids_str = \"; \".join(ids)\n",
    "print(\"所有馆藏编号：\", ids_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8c802eb3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "每个兴趣小组的报名人数： {'篮球': 2, '音乐': 3, '美术': 3, '足球': 3}\n",
      "报名人数最多的兴趣小组： ['音乐', '美术', '足球']\n",
      "所有报名学生姓名： 孙八, 张三, 李四, 王五, 赵六, 钱七\n",
      "所有兴趣小组名称： ['篮球', '美术', '足球', '音乐']\n"
     ]
    }
   ],
   "source": [
    "'''\n",
    "#### 编程题：班级兴趣小组统计\n",
    "\n",
    "某班同学的兴趣小组报名信息如下，每个元组包含学生姓名和其报名的兴趣小组（可能有多个）：\n",
    "\n",
    "students_groups = [\n",
    "    (\"张三\", [\"篮球\", \"音乐\"]),\n",
    "    (\"李四\", [\"美术\", \"音乐\", \"足球\"]),\n",
    "    (\"王五\", [\"足球\"]),\n",
    "    (\"赵六\", [\"篮球\", \"美术\"]),\n",
    "    (\"钱七\", [\"音乐\", \"足球\"]),\n",
    "    (\"孙八\", [\"美术\"])\n",
    "]\n",
    "\n",
    "要求：\n",
    "1. 统计每个兴趣小组的报名人数（用字典实现，键为兴趣小组，值为人数）。\n",
    "2. 找出报名人数最多的兴趣小组名称（如有并列，全部输出）。\n",
    "3. 输出所有报名过兴趣小组的学生姓名（去重后，按字母顺序，用英文逗号连接成字符串）。\n",
    "4. 输出所有兴趣小组名称（去重后，按字母顺序组成列表）。\n",
    "'''\n",
    "# 1. 统计每个兴趣小组的报名人数\n",
    "students_groups = [\n",
    "    (\"张三\", [\"篮球\", \"音乐\"]),\n",
    "    (\"李四\", [\"美术\", \"音乐\", \"足球\"]),\n",
    "    (\"王五\", [\"足球\"]),\n",
    "    (\"赵六\", [\"篮球\", \"美术\"]),\n",
    "    (\"钱七\", [\"音乐\", \"足球\"]),\n",
    "    (\"孙八\", [\"美术\"])\n",
    "]\n",
    "\n",
    "group_counts = {}\n",
    "for name, groups in students_groups:\n",
    "    for group in groups:\n",
    "        group_counts[group] = group_counts.get(group, 0) + 1\n",
    "print(\"每个兴趣小组的报名人数：\", group_counts)\n",
    "\n",
    "# 2. 找出报名人数最多的兴趣小组名称\n",
    "max_count = max(group_counts.values())\n",
    "most_popular = [group for group, count in group_counts.items() if count == max_count]\n",
    "print(\"报名人数最多的兴趣小组：\", most_popular)\n",
    "\n",
    "# 3. 输出所有报名过兴趣小组的学生姓名（去重后，按字母顺序，用英文逗号连接成字符串）\n",
    "student_names = sorted({name for name, _ in students_groups})\n",
    "students_str = \", \".join(student_names)\n",
    "print(\"所有报名学生姓名：\", students_str)\n",
    "\n",
    "# 4. 输出所有兴趣小组名称（去重后，按字母顺序组成列表）\n",
    "all_groups = sorted({group for _, groups in students_groups for group in groups})\n",
    "print(\"所有兴趣小组名称：\", all_groups)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1757bf39",
   "metadata": {},
   "source": [
    "##### 第四章 -程序控制结构、函数定义与使用"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6499e358",
   "metadata": {},
   "source": [
    "#### 编程题：快递费用计算器\n",
    "\n",
    "某快递公司按照以下规则收取快递费用：\n",
    "\n",
    "- 首重1公斤以内（含1公斤）收费8元；\n",
    "- 超过1公斤的部分，每增加1公斤（不足1公斤按1公斤计）加收5元；\n",
    "- 偏远地区（如输入的地区为“西藏”或“新疆”）总费用加收10元。\n",
    "\n",
    "请编写一个函数 `calculate_fee(weight, region)`，根据用户输入的包裹重量（单位：公斤，浮点数）和地区（字符串），返回应收快递费用。主程序循环接收用户输入，直到输入“exit”为止，输出每次计算的费用。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f8ee8233",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "快递费用：428元\n",
      "快递费用：428元\n",
      "程序结束。\n"
     ]
    }
   ],
   "source": [
    "def calculate_fee(weight, region):\n",
    "    # 首重8元，超重每公斤5元，偏远地区加收10元\n",
    "    base_fee = 8\n",
    "    if weight <= 1:\n",
    "        fee = base_fee\n",
    "    else:\n",
    "        # 向上取整\n",
    "        import math\n",
    "        extra = math.ceil(weight - 1)\n",
    "        fee = base_fee + extra * 5\n",
    "    if region in [\"西藏\", \"新疆\"]:\n",
    "        fee += 10\n",
    "    return fee\n",
    "\n",
    "while True:\n",
    "    user_input = input(\"请输入包裹重量（公斤）和地区（用空格分隔，或输入exit退出）：\")\n",
    "    if user_input.strip().lower() == \"exit\":\n",
    "        print(\"程序结束。\")\n",
    "        break\n",
    "    try:\n",
    "        weight_str, region = user_input.strip().split()\n",
    "        weight = float(weight_str)\n",
    "        fee = calculate_fee(weight, region)\n",
    "        print(f\"快递费用：{fee}元\")\n",
    "    except Exception as e:\n",
    "        print(\"输入格式有误，请重新输入。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d340a549",
   "metadata": {},
   "source": [
    "#### 编程题：判断素数并统计区间素数个数\n",
    "\n",
    "请编写如下功能：\n",
    "1. 定义一个函数 `is_prime(n)`，判断参数 n 是否为素数，返回布尔值。\n",
    "2. 定义一个函数 `count_primes(start, end)`，统计区间 [start, end] 内素数的个数。\n",
    "3. 主程序循环接收用户输入的两个正整数（start, end），输出区间内素数的数量，输入\"exit\"退出。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8c17a100",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2到80之间共有22个素数。\n",
      "程序结束。\n"
     ]
    }
   ],
   "source": [
    "def is_prime(n):\n",
    "    if n < 2:\n",
    "        return False\n",
    "    for i in range(2, int(n ** 0.5) + 1):\n",
    "        if n % i == 0:\n",
    "            return False\n",
    "    return True\n",
    "\n",
    "def count_primes(start, end):\n",
    "    count = 0\n",
    "    for num in range(start, end + 1):\n",
    "        if is_prime(num):\n",
    "            count += 1\n",
    "    return count\n",
    "\n",
    "while True:\n",
    "    user_input = input(\"请输入两个正整数start和end（用空格分隔，或输入exit退出）：\")\n",
    "    if user_input.strip().lower() == \"exit\":\n",
    "        print(\"程序结束。\")\n",
    "        break\n",
    "    try:\n",
    "        start_str, end_str = user_input.strip().split()\n",
    "        start, end = int(start_str), int(end_str)\n",
    "        if start > end or start < 1:\n",
    "            print(\"输入区间不合法，请重新输入。\")\n",
    "            continue\n",
    "        prime_count = count_primes(start, end)\n",
    "        print(f\"{start}到{end}之间共有{prime_count}个素数。\")\n",
    "    except Exception:\n",
    "        print(\"输入格式有误，请重新输入。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e81aac8",
   "metadata": {},
   "source": [
    "##### 第五章 -文件操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d284efbd",
   "metadata": {},
   "source": [
    "#### 编程题1：学生成绩文件读写\n",
    "\n",
    "请编写程序，完成以下功能：\n",
    "\n",
    "1. 用户输入若干学生姓名和成绩（格式如“张三 85”，输入“end”结束），将数据写入名为`students.txt`的文本文件，每行一个学生信息。\n",
    "2. 读取`students.txt`文件，统计成绩大于等于90分的学生人数，并输出所有学生的平均成绩。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4e3d4ff6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "成绩大于等于90分的学生人数：1\n",
      "所有学生的平均成绩：71.67\n"
     ]
    }
   ],
   "source": [
    "# 1. 输入学生信息并写入文件\n",
    "with open(\"../期末题目-by-student/students.txt\", \"w\", encoding=\"utf-8\") as f:\n",
    "    while True:\n",
    "        entry = input(\"请输入学生姓名和成绩（如“张三 85”，输入end结束）：\")\n",
    "        if entry.strip().lower() == \"end\":\n",
    "            break\n",
    "        f.write(entry.strip() + \"\\n\")\n",
    "\n",
    "# 2. 读取文件并统计\n",
    "scores = []\n",
    "high_score_count = 0\n",
    "with open(\"../期末题目-by-student/students.txt\", \"r\", encoding=\"utf-8\") as f:\n",
    "    for line in f:\n",
    "        parts = line.strip().split()\n",
    "        if len(parts) == 2:\n",
    "            name, score_str = parts\n",
    "            try:\n",
    "                score = float(score_str)\n",
    "                scores.append(score)\n",
    "                if score >= 90:\n",
    "                    high_score_count += 1\n",
    "            except ValueError:\n",
    "                continue\n",
    "if scores:\n",
    "    avg_score = sum(scores) / len(scores)\n",
    "    print(f\"成绩大于等于90分的学生人数：{high_score_count}\")\n",
    "    print(f\"所有学生的平均成绩：{avg_score:.2f}\")\n",
    "else:\n",
    "    print(\"没有有效成绩数据。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef11b667",
   "metadata": {},
   "source": [
    "#### 编程题2：文本文件字符/词语统计\n",
    "\n",
    "请编写程序，完成以下功能：\n",
    "\n",
    "1. 用户输入一段中英文混合文本，将其写入名为`text.txt`的文件。\n",
    "2. 读取`text.txt`文件，统计并输出其中出现次数最多的“词语”及其出现次数（中文按单字统计，英文按单词统计，忽略大小写和标点）。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a93e3575",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "出现次数最多的是：'喜'，出现了2次。\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "from collections import Counter\n",
    "\n",
    "# 1. 输入中英文混合文本并写入文件\n",
    "text = input(\"请输入一段中英文混合文本：\\n\")\n",
    "with open(\"../期末题目-by-student/text.txt\", \"w\", encoding=\"utf-8\") as f:\n",
    "    f.write(text)\n",
    "\n",
    "# 2. 读取文件并统计“词语”出现次数\n",
    "with open(\"../期末题目-by-student/text.txt\", \"r\", encoding=\"utf-8\") as f:\n",
    "    content = f.read().lower()\n",
    "    # 英文单词\n",
    "    en_words = re.findall(r\"[a-zA-Z]+\", content)\n",
    "    # 中文单字\n",
    "    zh_chars = re.findall(r\"[\\u4e00-\\u9fff]\", content)\n",
    "    # 合并统计\n",
    "    tokens = en_words + zh_chars\n",
    "    counter = Counter(tokens)\n",
    "    if counter:\n",
    "        most_common, count = counter.most_common(1)[0]\n",
    "        print(f\"出现次数最多的是：'{most_common}'，出现了{count}次。\")\n",
    "    else:\n",
    "        print(\"没有检测到词语或字符。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ecda7878",
   "metadata": {},
   "source": [
    "##### 第六章 -NumPy数组运算与矩阵运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "acf3553b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6f496b59",
   "metadata": {},
   "source": [
    "#### 编程题1：城市温度数据分析\n",
    "\n",
    "某地气象站记录了一周内每天的最高气温（单位：℃），数据如下：\n",
    "\n",
    "`[23.5, 25.1, 22.8, 24.6, 26.0, 27.3, 25.8]`\n",
    "\n",
    "请完成以下任务：\n",
    "\n",
    "1. 使用NumPy计算该周的平均气温、最高气温和最低气温。\n",
    "2. 计算每天与平均气温的差值，输出差值数组。\n",
    "3. 判断哪几天的气温高于平均气温，并输出对应的天数（下标从0开始）。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "cf33c83b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均气温：25.01℃，最高气温：27.3℃，最低气温：22.8℃\n",
      "每天与平均气温的差值： [-1.51428571  0.08571429 -2.21428571 -0.41428571  0.98571429  2.28571429\n",
      "  0.78571429]\n",
      "高于平均气温的天数下标： [1 4 5 6]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "temps = np.array([23.5, 25.1, 22.8, 24.6, 26.0, 27.3, 25.8])\n",
    "\n",
    "# 1. 平均、最高、最低气温\n",
    "avg_temp = np.mean(temps)\n",
    "max_temp = np.max(temps)\n",
    "min_temp = np.min(temps)\n",
    "print(f\"平均气温：{avg_temp:.2f}℃，最高气温：{max_temp}℃，最低气温：{min_temp}℃\")\n",
    "\n",
    "# 2. 每天与平均气温的差值\n",
    "diffs = temps - avg_temp\n",
    "print(\"每天与平均气温的差值：\", diffs)\n",
    "\n",
    "# 3. 高于平均气温的天数下标\n",
    "above_avg_days = np.where(temps > avg_temp)[0]\n",
    "print(\"高于平均气温的天数下标：\", above_avg_days)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9ca2dbe7",
   "metadata": {},
   "source": [
    "#### 编程题2：商品销量矩阵分析\n",
    "\n",
    "某超市统计了3种商品在4个季度的销量（单位：件），数据如下（行表示商品，列表示季度）：\n",
    "\n",
    "```\n",
    "[[120, 135, 150, 160],\n",
    " [80,  95,  100, 110],\n",
    " [200, 210, 220, 230]]\n",
    "```\n",
    "\n",
    "请完成以下任务：\n",
    "\n",
    "1. 使用NumPy计算每种商品的年总销量。\n",
    "2. 计算每个季度的总销量。\n",
    "3. 计算所有商品全年总销量。\n",
    "4. 计算每种商品各季度销量占全年销量的百分比（保留两位小数）。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a3951bc7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "每种商品年总销量： [565 385 860]\n",
      "每个季度总销量： [400 440 470 500]\n",
      "所有商品全年总销量： 1810\n",
      "各商品各季度销量占全年百分比：\n",
      " [[ 6.63  7.46  8.29  8.84]\n",
      " [ 4.42  5.25  5.52  6.08]\n",
      " [11.05 11.6  12.15 12.71]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "sales = np.array([\n",
    "    [120, 135, 150, 160],\n",
    "    [80,  95,  100, 110],\n",
    "    [200, 210, 220, 230]\n",
    "])\n",
    "\n",
    "# 1. 每种商品年总销量\n",
    "product_totals = np.sum(sales, axis=1)\n",
    "print(\"每种商品年总销量：\", product_totals)\n",
    "\n",
    "# 2. 每个季度总销量\n",
    "quarter_totals = np.sum(sales, axis=0)\n",
    "print(\"每个季度总销量：\", quarter_totals)\n",
    "\n",
    "# 3. 所有商品全年总销量\n",
    "total_sales = np.sum(sales)\n",
    "print(\"所有商品全年总销量：\", total_sales)\n",
    "\n",
    "# 4. 每种商品各季度销量占全年销量百分比\n",
    "percent = sales / total_sales * 100\n",
    "percent_rounded = np.round(percent, 2)\n",
    "print(\"各商品各季度销量占全年百分比：\\n\", percent_rounded)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
